local skel = fk.CreateSkill{
  name = "#ProhibitMove",
}

Fk:loadTranslationTable{
  ["#cancelMove"] = "%arg ： %card 不能移动",
}

local cancelmove = {
  global = true,
  can_refresh = function(self, event, target, player, data)
    if player.dead then return end
    for _, move in ipairs(data) do
      for _, info in ipairs(move.moveInfo) do
        local card = Fk:getCardById(info.cardId)
        if #card:getTableMark("#ProhibitMove-inhand") > 0 then
          return true
        end
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    local ids = {}
    local prohibit = {}
    local room = player.room
    for _, move in ipairs(data) do
      local move_info = {}
      for _, info in ipairs(move.moveInfo) do
        local card = Fk:getCardById(info.cardId)
        local owner = room:getCardOwner(card)
        local list = card:getTableMark("#ProhibitMove-inhand")
        if owner and move.proposer and #list > 0 and owner.id ~= move.proposer.id then
          table.insert(ids, info.cardId)
          table.insert(prohibit, {card.id,list[1]})
        else
          table.insert(move_info, info)
          if #list > 0 then
            room:setPlayerMark(room:getPlayerById(list[2]),list[3],0)
          end
        end
      end
      if #ids > 0 then
        move.moveInfo = move_info
      end
    end
    for _, v in ipairs(prohibit) do
      room:sendLog{
        type = "#cancelMove",
        card = {v[1]},
        arg = v[2],
      }
    end
  end,
}

skel:addEffect(fk.BeforeCardsMove, cancelmove)

return skel